import 'package:flutter/material.dart';

class MyPageView extends StatelessWidget{
  List<Widget> list=[
    Item1(),
    Item2(),
    Item3()
  ];
  @override
    Widget build(BuildContext context) {
      // TODO: implement build
      return  Scaffold(
          appBar: AppBar(
            title: Text("滑动视图PageView"),
          ),
          body:PageView.builder(
            scrollDirection: Axis.vertical,
            itemCount: list.length,
            itemBuilder: (BuildContext context,int index){
              return list[index];
            },
            controller: PageController(
              viewportFraction:0.8,
              initialPage: 1,
              keepPage: true
            ),
          )
        );
     
    }
}
class Item1 extends StatelessWidget{
  @override
    Widget build(BuildContext context) {
      // TODO: implement build
      return Container(
      decoration: BoxDecoration(
        color: Colors.greenAccent
      ),
    );
    }
}
class Item2 extends StatelessWidget{
  @override
    Widget build(BuildContext context) {
      // TODO: implement build
      return Container(
      decoration: BoxDecoration(
        color: Colors.amberAccent
      ),
    );
    }
}
class Item3 extends StatelessWidget{
  @override
    Widget build(BuildContext context) {
      // TODO: implement build
      return Container(
      decoration: BoxDecoration(
        color: Colors.blueGrey
      ),
    );
    }
}